#!/usr/bin/env python
#-*- coding:utf-8 -*-
# author:zhang
# datetime:2019/4/29 19:45
# software: PyCharm

# 验证用户是否登录

from django.shortcuts import redirect, reverse
from django.utils.deprecation import MiddlewareMixin

class AuthMiddleware(MiddlewareMixin):
    
    def process_request(self, request):
        pass_list = ["/admin", reverse("login"), reverse("register")]
        
        print(request.path_info)
        if request.path_info in pass_list:
            return 
        
        is_login = request.session.get("is_login")
        print("is_login", is_login)
        
        if not is_login:
            return redirect(reverse("login"))
        
        











